Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-use attachment in exportForwarders to handle ambiguous overloads #21518

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

wjoel
Copy link
Contributor

@wjoel wjoel commented Aug 30, 2024

exportForwarders can be called more than once for the same expression if there are ambiguous overloads.

Closes #21071

@@ -1454,7 +1454,7 @@ class Namer { typer: Typer =>

addForwarders(selectors, Nil)
val forwarders = avoidClashes(buf.toList)
exp.pushAttachment(ExportForwarders, forwarders)
exp.putAttachment(ExportForwarders, forwarders)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, it doesn't (at a glance) seem like this will ever give a different result, so maybe this is better?

      exp.getAttachment(ExportForwarders).getOrElse:
        addForwarders(selectors, Nil)
        val forwarders = avoidClashes(buf.toList)
        exp.putAttachment(ExportForwarders, forwarders)
        forwarders

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's try that alternative. It seems better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, PR updated.

exportForwarders can be called more than once for the same expression
if there are ambiguous overloads.

Just return the already computed ExportForwarders if that happens.

Closes scala#21071
@wjoel wjoel changed the title Use putAttachment in exportForwarders to handle ambiguous overloads Re-use attachment in exportForwarders to handle ambiguous overloads Sep 3, 2024
@sjrd sjrd enabled auto-merge September 3, 2024 15:42
@sjrd sjrd merged commit 21a3d39 into scala:main Sep 3, 2024
26 checks passed
@wjoel wjoel deleted the fix-21071 branch September 3, 2024 18:41
@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export statement + ambiguous overload crash compiler
3 participants